﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;

public partial class SearchContact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        GridView2.Visible = false;
        if (!IsPostBack)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString.ToString());


            lab_membernames.Text = Session["name"].ToString();
            
        }
    }
    protected void Btn_Search_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString.ToString());
        GridView1.Visible = false;
        GridView2.Visible = true;
        //con.Open();
        //string query = "select Name,Age,PhoneNo,Email,Location,Gender,BirthDay,Address,ImagePath from MGmaster where MGD like'" + SearchText.Text + "%'";
        //SqlCommand com = new SqlCommand(query, con);
        //SqlDataReader dr;
        //dr = com.ExecuteReader();


        //if (dr.HasRows)
        //{
        //    dr.Read();

        //    Rep_Bind();
        //    GridView2.Visible = true;


        //   SearchText.Text = "";
        //    // RecordNot.Text = "";
        //}
        //else
        //{
        //    GridView2.Visible = false;
        //    Lab_Notfond.Text = " info not found";
        //    // RecordNot.Visible = true;
        //    // RecordNot.Text = "The search Term " + Searchtxt.Text + " &nbsp;Is Not Available in the Records"; ;

        //}
        // GVserh.Visible = true;
        /*  SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString.ToString());
          SqlDataAdapter sda = new SqlDataAdapter("select MGC_SLno,MGD from MGmaster where MGD='" + Searchtxt.Text + "'", Con);
          DataSet ds = new DataSet();
          Con.Open();
          sda.Fill(ds);
          Con.Close();

          try
          {
              if (ds.Tables[0].Rows[0].ItemArray.GetValue(1).ToString() == Searchtxt.Text)
              {

                  GridViewMGC.DataSource = ds;
                  GridViewMGC.DataBind();
              }
              else
              {
                  RecordNot.Visible = true;
                  GridViewMGC.Visible = false;
              }
          }
          catch (Exception ex)
          {
              RecordNot.Visible = true;
              GridViewMGC.Visible = false;
          }*/
    }
}